
import java.rmi.registry.*;
import java.rmi.*;

/**
 *
 * @author Mario
 */
public class rmiEmisorServidor {

    private static interfazReceptorServidor rmiReceptorServidor;
    private static Registry registro;
    private static String ipReceptorServidor;
    private static String puertoReceptorServidor = "3230";

    public rmiEmisorServidor(String str) {

        ipReceptorServidor = str;
    }

    public static boolean conexioReceptorServidor() {
        try {
            registro = LocateRegistry.getRegistry(ipReceptorServidor, (new Integer(puertoReceptorServidor)).intValue());
            rmiReceptorServidor = (interfazReceptorServidor) (registro.lookup("rmiReceptorServidor"));
            return true;
        } catch (NotBoundException ex) {
            System.out.println(ex);
            return false;
        } catch (RemoteException ex) {            
            System.out.println(ex);
            return false;
        }
    }

    public boolean enviarDatosServidor(Servidor servidor){
        try {
            rmiReceptorServidor.recibirServidor(servidor);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    } 
}
